package mysql

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB

func init() {
	var err error
	dsn := "root:123456@tcp(120.27.208.86:3305)/2109A?charset=utf8mb4&parseTime=True&loc=Local"
	DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		return
	}
	err = DB.AutoMigrate(&Book{})
	if err != nil {
		return
	}
}

type Book struct {
	gorm.Model
	BookName string
	Author   string
	Class    string
	Title    string
	Price    float64
	Sales    int64
}

type Orders struct {
	gorm.Model
	GoodsID    int
	OrderID    string
	UserID     int
	Status     int8
	TotalPrice string
	Payment    string
	Address    string
}
